<template>
  <div class="myCenter">
    <!-- 用户信息 -->
    <div class="user-meta">
      <div class="avatar">
        <img :src="userInfo.avatar" alt="" />
      </div>
      <h4>{{ userInfo.account }}</h4>
    </div>
    <div class="item">
      <a href="javascript:;">
        <span class="iconfont icon-icon-hyklb"></span>
        <p>会员中心</p>
      </a>
      <a href="javascript:;">
        <span class="iconfont icon-shouye"></span>
        <p>安全设置</p>
      </a>
      <a href="javascript:;">
        <span class="iconfont icon-ditu_dingwei"></span>
        <p>地图管理</p>
      </a>
    </div>
  </div>
  <div class="like-container">
    <div class="header">
      <h4>猜你喜欢</h4>
    </div>
    <div class="goods-list">
      <GoodsItem v-for="good in likeList" :good="good" :key="good.id" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineOptions, ref, onMounted } from "vue";
//引入用户信息的仓库
import { useUserStore } from "@/stores/modules/userStore";
import { storeToRefs } from "pinia";
import { reqGetLikeList } from "@/apis/user";
//引入公用模块模版
import GoodsItem from "@/views/Home/components/GoodsItem.vue";
defineOptions({
  name: "MyCenter",
});
const userStore = useUserStore();
// 解构仓库用户信息数据
const { userInfo } = storeToRefs(userStore);
let likeList = ref([]);
onMounted(() => {
  getLikeList();
});
//获取个人中心好物数据
const getLikeList = async () => {
  let res: any = await reqGetLikeList({ limit: 4 });
  console.log(res);
  likeList.value = res.result;
};
</script>

<style scoped lang="scss">
.myCenter {
  display: flex;
  height: 132px;
  background: url(@/assets/images/center-bg.png) no-repeat center / cover;
  .user-meta {
    flex: 1;
    display: flex;
    align-items: center;
    .avatar {
      width: 85px;
      height: 85px;
      border-radius: 50%;
      overflow: hidden;
      margin-left: 60px;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
  h4 {
    padding-left: 26px;
    font-size: 18px;
    font-weight: normal;
    color: white;
  }
  .item {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    a {
      color: #fff;
      text-align: center;
      padding-right: 40px;
      .iconfont {
        font-size: 32px;
      }
      p {
        line-height: 32px;
      }
    }
  }
}
.like-container {
  margin-top: 20px;
  height: 400px;
  background-color: #fff;
  padding: 0 20px;

  .header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    height: 66px;
    padding: 18px;
    border-bottom: 1px solid #f5f5f5;
    h4 {
      font-size: 22px;
      font-weight: 400;
    }
  }
  .goods-list {
    display: flex;
    margin-top: 10px;
    justify-content: space-around;
  }
}
</style>
